package com.stb.client.menu;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.stb.client.dialog.MessageBox;
import com.stb.client.remote.UserService;
import com.stb.client.remote.UserServiceAsync;

public class ActivateUserCommand implements Command {
	
	private final String params;
	public ActivateUserCommand(String params) {
		this.params = params;
	}
	
	@Override
	public void execute() {
		UserServiceAsync userService = (UserServiceAsync) GWT.create(UserService.class);
		userService.activate(this.params, new AsyncCallback<Void>() {
			@Override
			public void onSuccess(Void result) {
				MessageBox.alert("Activate", "Your account is now active.");
			}
			
			@Override
			public void onFailure(Throwable caught) {
				MessageBox.alert("Activate Failed", caught.getMessage());
			}
		});
	}
}
